/**
 * Crea al personaje Bomberman.
 * @constructor
 * @param {Number} x - pos x.
 * @param {Number} y - pos y.
 * @param {Number} w - anchura.
 * @param {Number} h - altura.
 * @param {Number} rx - punto de registro de objeto x.
 * @param {Number} ry - punto de registro de objeto y.
 * @param {Number} sx - escala de objeto x.
 * @param {Number} sy - escala de objeto y.
 */
Bomberman = function(x, y, w, h, rx, ry, sx, sy , imgId) {
    this.animation = null;
    GameObject.call(this, x, y, w, h, rx, ry, sx, sy);
    this.facingRight = true;
    this.currAnimationName = "";
    this.imgId = imgId||"bombermanWalk";
};

Bomberman.prototype = Object.create(GameObject.prototype);

Bomberman.prototype.loadAnimations = function() {
    var bombermanImg = GameSys.imgLoader.loadedImages[this.imgId];
    var walkSlowdownFactor = 5;

    // create spritesheet and assign the associated data.
    var spriteSheet = new createjs.SpriteSheet({
        //image to use
        images : [bombermanImg],
        //width, height & registration point of each sprite
        frames : {
            width : this.w,
            height : this.h,
            regX : this.rx,
            regY : this.ry
        },
        // To slow down the animation loop of the sprite, we set the frequency to 4 to slow down by a 3x factor
        animations : {
            walk_d : [0, 4, "walk_d", walkSlowdownFactor],
            walk_r : [5, 9, "walk_r", walkSlowdownFactor],
            walk_u : [10, 14, "walk_u", walkSlowdownFactor],
            walk_l : [15, 19, "walk_l", walkSlowdownFactor],
        }
    });
    this.spriteSheet=spriteSheet;

    
    // create a BitmapSequence instance to display and play back the sprite sheet:
    var bmpAnimation = new createjs.BitmapAnimation(spriteSheet);
    /*de la siguiente manera es posible escalar una animacion*/
    bmpAnimation.scaleX = this.sx;
    bmpAnimation.scaleY = this.sy;

    // set the registration point (the point it will be positioned and rotated around)
    // to the center of the frame dimensions:
    bmpAnimation.regX = bmpAnimation.spriteSheet.frameWidth / 2 | 0;
    bmpAnimation.regY = bmpAnimation.spriteSheet.frameHeight / 2 | 0;
    //bmpAnimation.regX = 0;
    //bmpAnimation.regY = 0;

    bmpAnimation.gotoAndPlay("walk_d");

    // set up a shadow. Note that shadows are ridiculously expensive. You could display hundreds
    // of animated rats if you disabled the shadow.
    bmpAnimation.shadow = new createjs.Shadow("#454", 0, 5, 4);

    bmpAnimation.name = "bombermanWalk";

    // have each monster start at a specific frame
    bmpAnimation.currentFrame = 0;

    this.animation = bmpAnimation;

    this.update();
};
//loadAnimations

